package com.loren.demo31.controller;

import com.loren.demo31.groovy.GroovyScriptExecutor;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/groovy-script")
public class GroovyScriptController {

    private final GroovyScriptExecutor groovyScriptExecutor;

    @PostMapping
    public Object execute(@RequestBody String scriptText) {
        return this.groovyScriptExecutor.executeScriptText(scriptText);
    }

}
